package com.openarena.model.dao;

import com.openarena.persistence.HibernateUtil;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.hibernate.classic.Session;
import org.hibernate.Transaction;

public class InfArenaDAO {

    private static final Logger logger = Logger.getLogger(InfArenaDAO.class.getCanonicalName());

    protected Session getSession() {
        return HibernateUtil.getSession();
    }

    protected void close(Session session) {
        try {
            if (session != null) {
                session.close();
            }
        } catch (Exception e) {
            logger.log(Level.SEVERE, "", e);
        }
    }

    protected void close(Transaction transaction) {
        try {
            if (transaction != null && !transaction.wasCommitted()) {
                transaction.rollback();
            }
        } catch (Exception e) {
            logger.log(Level.SEVERE, "", e);
        }
    }
}
